package 递归.pow;

public class Main {
    public double myPow(double x, int n) {
        pow(x, n);
        return n < 0 ?1/pow(x,-n) : pow(x,n);
    }
    public double pow(double x, int n) {
        if(n == 0){
            return 1;
        }
        double rel = pow(x, n / 2);
        return n%2 == 0?rel*rel:rel*rel*x;
    }
}
